#!/usr/bin/python
# coding=utf8

import json
import sys
from database import Storage

storage = Storage()

dump = json.loads(sys.stdin.read())
udump = dump['data']
if type(udump) != list:
    udump = [udump]
udump = udump[-1]
storage.update_main(udump)
print "Content-Type: application/json\n"
print json.dumps({'success': True, 'data':udump})